<template>
  <div class="content">
    <toolBtn
        :toolList="toolList.toolList"
        @toolChange="toolChange"
    >
    </toolBtn>
    <el-form
        ref="brandFormRef"
        label-width="100px"
        :model="form.formData"
        :rules="form.formFules"
        class="brandFormRef"
    >
      <formLabel
          formType="1"
          :publicForm="form.basicForm"
          :formData="form.formData"
          @formSelectEmit="formSelectEmit"
      >
      </formLabel>
      <formLabel
          formType="2"
          :publicForm="form.bankForm"
          :formData="form.formData"
          :tableData="form.formData.sysBankCardL"
          :detailsbool="false"
      >
        <template v-slot:formTableBtn>
          <div class="base_btn">
            <el-button
                type="primary"
                size="small"
                @click="changeFormDataList('add',['sysBankCardL'])"
            >
              新增
            </el-button>
            <el-button
                type="primary"
                size="small"
                @click="changeFormDataList('del',['sysBankCardL'])"
            >
              删除
            </el-button>
          </div>
        </template>
      </formLabel>
      <formLabel
          formType="2"
          :publicForm="form.buttForm"
          :tableData="form.formData.salesmanList"
          @formSelectEmit="formSelectEmit"
      >
        <template v-slot:formTableBtn>
          <div class="base_btn">
            <el-button
                type="primary"
                size="small"
                @click="changeFormDataList('add',['salesmanList'])"
            >
              新增
            </el-button>
            <el-button
                type="primary"
                size="small"
                @click="changeFormDataList('del',['salesmanList'])"
            >
              删除
            </el-button>
          </div>
        </template>
        <template v-slot:formTableChildren="formTableChildren">
          <div class="form_label_temp">
            <!--联系人-->
            <formLabel
                formType="2"
                :publicForm="form.linkmanList"
                :tableData="form.formData.salesmanList[formTableChildren.index].linkmanList"
                @formSelectEmit="formSelectEmit"
            >
              <template v-slot:formTableBtn>
                <div class="base_btn">
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('add',['salesmanList','linkmanList'],formTableChildren.index)"
                  >
                    新增
                  </el-button>
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('del',['salesmanList','linkmanList'],formTableChildren.index)"
                  >
                    删除
                  </el-button>
                </div>
              </template>
            </formLabel>
            <!--付款条款-->
            <formLabel
                formType="2"
                :publicForm="form.termsNew"
                :tableData="form.formData.salesmanList[formTableChildren.index].termsNew"
                @formSelectEmit="formSelectEmit"
            >
              <template v-slot:formTableBtn>
                <div class="base_btn">
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('add',['salesmanList','termsNew'],formTableChildren.index)"
                  >
                    新增
                  </el-button>
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('del',['salesmanList','termsNew'],formTableChildren.index)"
                  >
                    删除
                  </el-button>
                </div>
              </template>
            </formLabel>
            <!--收货地址-->
            <formLabel
                formType="2"
                :publicForm="form.shippingAddressNew"
                :tableData="form.formData.salesmanList[formTableChildren.index].shippingAddressNew"
                @formSelectEmit="formSelectEmit"
            >
              <template v-slot:formTableBtn>
                <div class="base_btn">
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('add',['salesmanList','shippingAddressNew'],formTableChildren.index)"
                  >
                    新增
                  </el-button>
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('del',['salesmanList','shippingAddressNew'],formTableChildren.index)"
                  >
                    删除
                  </el-button>
                </div>
              </template>
            </formLabel>
            <!--固定收货要求-->
            <formLabel
                formType="2"
                :publicForm="form.fixedFlowRuleNew"
                :tableData="form.formData.salesmanList[formTableChildren.index].fixedFlowRuleNew"
                @formSelectEmit="formSelectEmit"
            >
              <template v-slot:formTableBtn>
                <div class="base_btn">
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('add',['salesmanList','fixedFlowRuleNew'],formTableChildren.index)"
                  >
                    新增
                  </el-button>
                  <el-button
                      type="primary"
                      size="small"
                      @click="changeFormDataList('del',['salesmanList','fixedFlowRuleNew'],formTableChildren.index)"
                  >
                    删除
                  </el-button>
                </div>
              </template>
            </formLabel>

          </div>
        </template>
      </formLabel>
    </el-form>
  </div>
</template>

<script>
import {reactive, ref, toRaw, onBeforeMount, getCurrentInstance} from "vue"
import {useRouter} from "vue-router";
import {
  getCountryList,
  getCityList,
  getUserListByRole,
  setDictionaryLabelAndVal,
  getCurrencyListHand,
  getObjectKey
} from "../../../utils/apiCommon.js"
import * as math from 'mathjs'

export default {
  name: "customerDetails",
  components: {},
  data() {
    return {}
  },
  setup() {
    console.log(math.round(math.add(2092.45, 1.95), 5))
    const {proxy} = getCurrentInstance()
    let formRef = ref();
    let router = useRouter()
    let {type} = router.currentRoute.value.query;
    let toolList = reactive({
      toolList: [
        {id: "3", label: "保存", ismul: false},
      ]
    })
    const form = reactive({
      formData: {
        uuid: '',
        customerNum: '',
        customerName: '',
        simpleName: '',
        superiorName: '',
        archivesType: '',
        localCustomerName: '',
        companies: '',
        approveStatus: 1,
        url: '',
        developLevel: '',
        industry: '',
        countryCity: '',
        remark: '',
        dictValueNum: '',
        currencyNum: 'USD',
        initQuota: '0',
        approvedQuota: '',
        availableQuota: '',
        usedQuota: '',
        cityVal: '',
        countryVal: '',
        sysBankCardL: [
          {
            bankName: '',
            beneficiaryName: '',
            accountNumber: '',
            officeAddress: '',
            bankCode: '',
            branchCode: '',
            swiftCode: ''
          },
        ],
        salesmanList: [
          {
            saleNickName: '',
            saleUserId: '',
            belongOrganization: '',
            belongOrganizationId: '',
            busOrganization: '',
            busOrganizationId: '',
            contSource: '',
            contTransactionWay: '',
            currency: '',
            creditAmt: '',
            availableQuota: '',
            linkmanOpt: [],
            termsOpt: [],
            addrOpt: [],
            invoiceOpt: [],
            fixedOpt: [],
            linkmanList: [
              {
                contName: '',
                contPhone: '',
                contEmail: '',
                contPositionState: 1,
                contPosition: '',
                contDutyProject: '',
                contRemark: ''
              },
              {
                contName: '',
                contPhone: '',
                contEmail: '',
                contPositionState: 1,
                contPosition: '',
                contDutyProject: '',
                contRemark: ''
              }
            ],
            termsNew: [
              {
                termsInfo: ''
              }
            ],
            shippingAddressNew: [
              {
                contCompany: '',
                contName: '',
                contPhone: '',
                contAddr: '',
                contRemark: ''
              }
            ],
            // 发票地址
            invoiceNew: [
              {
                contCompany: '',
                contName: '',
                contAddr: '',
                contRemark: '',
                contPhone: ''
              }
            ],
            // 物流要求
            fixedFlowRuleNew: [
              {
                contProject: '',
                contRequire: '',
                contItem: '',
                contRemark: ''
              }
            ],
            termsNewupload: []
          },
          {
            isShow: true,
            delivery: true,
            accessory: false,
            invoice: true,
            addr: true,
            payment: true,
            linkmanOff: true,
            saleNickName: '',
            saleUserId: '',
            belongOrganization: '',
            belongOrganizationId: '',
            busOrganization: '',
            busOrganizationId: '',
            contSource: '',
            contTransactionWay: '',
            currency: '',
            creditAmt: '',
            availableQuota: '',
            linkmanOpt: [],
            termsOpt: [],
            addrOpt: [],
            invoiceOpt: [],
            fixedOpt: [],
            termsRadio: null,
            addrRadio: null,
            invoiceRadio: null,
            flowRadio: null,
            linkmanList: [
              {
                contName: '',
                contPhone: '',
                contEmail: '',
                contPositionState: 1,
                contPosition: '',
                contDutyProject: '',
                contRemark: ''
              },
              {
                contName: '',
                contPhone: '',
                contEmail: '',
                contPositionState: 1,
                contPosition: '',
                contDutyProject: '',
                contRemark: ''
              }
            ],
            termsNew: [
              {
                termsInfo: ''
              }
            ],
            shippingAddressNew: [
              {
                contCompany: '',
                contName: '',
                contPhone: '',
                contAddr: '',
                contRemark: ''
              }
            ],
            // 发票地址
            invoiceNew: [
              {
                contCompany: '',
                contName: '',
                contAddr: '',
                contRemark: '',
                contPhone: ''
              }
            ],
            // 物流要求
            fixedFlowRuleNew: [
              {
                contProject: '',
                contRequire: '',
                contItem: '',
                contRemark: ''
              }
            ],
            termsNewupload: []
          }
        ]
      },
      basicForm: {
        title: '基本信息',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '客户编码',
            prop: 'customerNum',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: true, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 4
          },
          {
            label: '客户',
            prop: 'customerName',
            type: 'text',
            disabled: false,
            placeholder: '请输入客户',
            colSpan: 6,
            option: [],
            isFilterable: true, //是否搜索
            isMultiple: false,//是否多选
            clearable: false,
            addPath: '',//当前选项没有数据时，跳转到新增页面的地址,
            selectTableData: [],
            contacts: [
              {prop: 'companyNum', label: '客户编码', width: '120', align: 'center'},
              {prop: 'customerName', label: '客户名称', width: '120', align: 'center'},
              {prop: 'saleNickName', label: '销售人员', width: '120', align: 'center'},
              {prop: 'po', label: '是否po', align: 'center'}
            ],
            isHttpType: '9',
            otherData: {oldCustomerName: '', toCustomerName: ''}
          },
          {
            label: '当地客户名',
            prop: 'localCustomerName',
            type: 'text',
            disabled: false,
            placeholder: '请输入当地客户名',
            colSpan: 6
          },
          {
            label: '上级客户',
            prop: 'superiorName',
            type: 'text',
            disabled: false,
            placeholder: '请输入上级客户',
            colSpan: 6,
            option: [],
            isFilterable: true, //是否搜索
            isMultiple: false,//是否多选
            clearable: false,
            addPath: '',//当前选项没有数据时，跳转到新增页面的地址,
            selectTableData: [],
            contacts: [
              {prop: 'companyNum', label: '客户编码', width: '120', align: 'center'},
              {prop: 'customerName', label: '客户名称', width: '120', align: 'center'},
              {prop: 'saleNickName', label: '销售人员', width: '120', align: 'center'},
              {prop: 'po', label: '是否po', align: 'center'}
            ],
            isHttpType: '9',
            otherData: {oldCustomerName: '', toCustomerName: ''}
          },
          {
            label: '简称',
            prop: 'simpleName',
            type: 'text',
            disabled: false,
            placeholder: '请输入简称',
            colSpan: 4
          },
          {
            label: '审批状态',
            prop: 'approveStatus',
            type: 'select',
            disabled: true,
            placeholder: '请输入审批状态',
            option: [
              {label: '暂存', value: 1},
              {label: '待审批', value: 2},
              {label: '已审批', value: 3}
            ],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '网址',
            prop: 'url',
            type: 'text',
            disabled: false,
            placeholder: '请输入网址',
            colSpan: 4
          },
          {
            label: '客户标签',
            prop: 'developLevel',
            type: 'select',
            disabled: false,
            placeholder: '请输入客户标签',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '客户类型',
            prop: 'customerType',
            type: 'select',
            disabled: false,
            placeholder: '请输入客户类型',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '所属行业',
            prop: 'industry',
            type: 'select',
            disabled: false,
            placeholder: '请输入所属行业',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '国家',
            prop: 'countryVal',
            type: 'select',
            disabled: false,
            placeholder: '请输入国家',
            option: [],
            isFilterable: true, //是否搜索
            clearable: true,
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '城市',
            prop: 'cityVal',
            type: 'select',
            disabled: false,
            placeholder: '请输入城市',
            option: [],
            isFilterable: true, //是否搜索
            clearable: true,
            isMultiple: false,//是否多选
            isLoadMore: true,//是否下拉加载更多
            addPath: '',
            colSpan: 4
          },
          {
            label: '备注',
            prop: 'remark',
            type: 'text',
            disabled: false,
            placeholder: '请输入备注',
            colSpan: 4
          },
          {
            label: '创建组织',
            prop: 'deptName',
            type: 'text',
            disabled: true,
            placeholder: '请输入创建组织',
            colSpan: 4
          },
          {
            label: '客户档案类型',
            prop: 'archivesType',
            type: 'select',
            disabled: false,
            placeholder: '请选择客户档案类型',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          }
        ]
      },
      bankForm: {
        title: '银行信息',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '收款银行',
            prop: 'bankName',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          },
          {
            label: '收款公司',
            prop: 'beneficiaryName',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          },
          {
            label: '收款账号',
            prop: 'accountNumber',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          },
          {
            label: 'OfficeAddress',
            prop: 'officeAddress',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          },
          {
            label: 'BankCode',
            prop: 'bankCode',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          },
          {
            label: 'BranchCode',
            prop: 'branchCode',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          },
          {
            label: 'SwiftCode',
            prop: 'swiftCode',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 6
          }
        ]
      },
      buttForm: {
        title: '对接信息',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '销售人员',
            prop: 'saleNickName',
            type: 'select',
            disabled: false,
            placeholder: '请选择销售人员',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '客户来源',
            prop: 'contSource',
            type: 'select',
            disabled: false,
            placeholder: '请选择客户来源',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '交易方式',
            prop: 'contTransactionWay',
            type: 'select',
            disabled: false,
            placeholder: '请选择交易方式',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
          {
            label: '额度币种',
            prop: 'currency',
            type: 'select',
            disabled: false,
            placeholder: '请选择额度币种',
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
            colSpan: 4
          },
        ]
      },
      linkmanList: {
        title: '联系人',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '联系人',
            prop: 'contName',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入联系人',
            colSpan: 4
          },
          {
            label: '联系方式',
            prop: 'contPhone',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入联系方式',
            colSpan: 4
          },
          {
            label: '邮箱',
            prop: 'contEmail',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入邮箱',
            colSpan: 4
          },
          {
            label: '地址',
            prop: 'contPosition',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入客户编码',
            colSpan: 4
          },
        ]
      },
      termsNew: {
        title: '付款条款',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '付款条款',
            prop: 'termsInfo',
            type: 'select', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请选择付款条款',
            colSpan: 4,
            option: [],
            isFilterable: false, //是否搜索
            isMultiple: false,//是否多选
            addPath: '',
          },

        ]
      },
      shippingAddressNew: {
        title: '收货地址',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '公司',
            prop: 'contCompany',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入公司',
            colSpan: 4
          },
          {
            label: '联系人',
            prop: 'contName',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入联系人',
            colSpan: 4
          },
          {
            label: '联系电话',
            prop: 'contPhone',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入联系电话',
            colSpan: 4
          },
          {
            label: '地址',
            prop: 'contAddr',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入地址',
            colSpan: 4
          },
          {
            label: '备注',
            prop: 'contRemark',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入备注',
            colSpan: 4
          },
        ]
      },
      fixedFlowRuleNew: {
        title: '固定收货要求',
        isTitle: true,
        showSearch: true,
        data: [
          {
            label: '项目',
            prop: 'contProject',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入项目',
            colSpan: 4
          },
          {
            label: '要求',
            prop: 'contRequire',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入要求',
            colSpan: 4
          },
          {
            label: '注意事项',
            prop: 'contItem',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入注意事项',
            colSpan: 4
          },
          {
            label: '备注',
            prop: 'contRemark',
            type: 'text', //text 文本  select 下拉  data 日期选择
            disabled: false, //是否禁用
            placeholder: '请输入备注',
            colSpan: 4
          },
        ]
      },

      formFules: {
        customerNum: [{required: true, message: '客户编码不能为空', trigger: 'blur'}],
        customerName: [{required: true, message: '客户不能为空', trigger: 'blur'}],
        localCustomerName: [{required: true, message: '当地客户名不能为空', trigger: 'blur'}],
        simpleName: [{required: true, message: '简称不能为空', trigger: 'blur'}],
        developLevel: [{required: true, message: '客户标签不能为空', trigger: 'change'}],
        industry: [{required: true, message: '所属行业不能为空', trigger: 'change'}],
        tradeRemark: [{required: true, message: '行业备注不能为空', trigger: 'blur'}],
        productSequence: [{required: true, message: '产品系列不能为空', trigger: 'change'}]
      }
    })
    if (type == 'add') {
      console.log("sads")
    } else {

    }
    let countryIndex = "";
    let cityIndex = "";
    let developIndex = "";
    let customerIndex = "";
    let industryIndex = "";
    let archivesTypeIndex = "";
    let contSourceIndex = "";
    let saleNickIndex = "";
    let transactionIndex = "";
    let currencyIndex = "";
    form.basicForm.data.forEach((item, index) => {
      if (item.prop == "countryVal") {
        countryIndex = index
      }
      if (item.prop == "cityVal") {
        cityIndex = index
      }
      if (item.prop == "developLevel") {
        developIndex = index
      }
      if (item.prop == "customerType") {
        customerIndex = index
      }
      if (item.prop == "industry") {
        industryIndex = index
      }
      if (item.prop == "archivesType") {
        archivesTypeIndex = index
      }
    })
    form.buttForm.data.forEach((item, index) => {
      if (item.prop == "contSource") {
        contSourceIndex = index
      }
      if (item.prop == "saleNickName") {
        saleNickIndex = index
      }
      if (item.prop == 'contTransactionWay') {
        transactionIndex = index
      }
      // currency
      if (item.prop == 'currency') {
        currencyIndex = index
      }
    })
    //初始化 人员回调函数
    const userCallback = (arr) => {
      // console.log("userCall", arr)
    }
    /*
    * 销售人员
    * */
    let userParams = {role: '销售', content: '', 'pageNum': 1, 'pageSize': 100}
    getUserListByRole(userParams, form.buttForm.data[saleNickIndex], userCallback)

    /*
    * 币种
    * */
    const currencyCallback = (arr) => {
      // console.log("currencyCallback", arr)
    }
    let currencyParams = {status: '1'}
    getCurrencyListHand(currencyParams, form.buttForm.data[currencyIndex], currencyCallback);
    /*
    * 国家城市
    * */
    getCountryList(form.basicForm.data[countryIndex])
    getCityList("", form.basicForm.data[cityIndex])


    let dictionaryList = JSON.parse(sessionStorage.getItem("dictionaryList"));
    if (dictionaryList) {
      /****/
      let developLevel = setDictionaryLabelAndVal(dictionaryList.developLevel);
      let customerType = setDictionaryLabelAndVal(dictionaryList.customerType);
      let industry = setDictionaryLabelAndVal(dictionaryList.industry);
      let onlineDevelopLevel = setDictionaryLabelAndVal(dictionaryList.onlineDevelopLevel);
      let custFrom = setDictionaryLabelAndVal(dictionaryList.custFrom);
      let transactionWay = setDictionaryLabelAndVal(dictionaryList.transactionWay);
      let paymentProvision = setDictionaryLabelAndVal(dictionaryList.paymentProvision);
      form.basicForm.data[developIndex].option = developLevel
      form.basicForm.data[customerIndex].option = customerType
      form.basicForm.data[industryIndex].option = industry
      form.basicForm.data[archivesTypeIndex].option = onlineDevelopLevel
      form.buttForm.data[contSourceIndex].option = custFrom
      form.buttForm.data[transactionIndex].option = transactionWay
      form.termsNew.data[0].option = paymentProvision
    }
    /*
    * 组件下拉选择回调方法
    * */
    const formSelectEmit = (val, currentItem, $index, obj) => {
      console.log("val", val)
      console.log("currentItem", currentItem)
      console.log("$index", $index)
      console.log("obj", obj)
      if (currentItem.prop == "countryVal") {
        form.formData.cityVal = ""
        getCityList(val, form.basicForm.data[cityIndex])
      }
    }
    const toolChange = (e) => {
      if (e == "3") {
        console.log(form.formData)
      }
    }
    const changeFormDataList = (type, prop, columnIndex) => {
      let formData = JSON.parse(JSON.stringify(toRaw(form.formData)));
      let formProp = getObjectKey(formData, prop, 1, columnIndex);
      if (type == 'add') {
        let formObj = JSON.parse(JSON.stringify(formProp[0]))
        let obj = {}
        Object.keys(formObj).forEach(key => {
          switch (typeof formObj[key]) {
            case 'string':
              obj[key] = '';
              break;
            case 'boolean':
              obj[key] = formObj[key];
              break;
            case 'number':
              obj[key] = 0;
              break;
            case 'object':
              if (Array.isArray(formObj[key])) {
                if (formObj[key].length == 0) {
                  obj[key] = []
                } else {
                  let params = formObj[key][0];
                  Object.keys(params).forEach(key => (params[key] = ""));
                  obj[key] = [params]
                }
              } else {
                obj[key] = ''
              }
              break;
          }
        })
        obj["isRandom"] = Math.floor(Math.random() * 100000000)
        formProp.push(obj)
        /*console.log("formData", formData)
        console.log("form.formData", form.formData)*/
      } else if (type == 'del') {
        if (formProp.length == 1) {
          proxy.$message({
            type: "warning",
            message: "列表首项,不能删除!"
          })
          return false
        }
        formProp.splice(formProp.length - 1, 1)
      }
      form.formData = formData
    }
    return {
      formRef,
      form,
      toolList,
      formSelectEmit,
      toolChange,
      changeFormDataList
    }
  },
}
</script>

<style scoped lang="scss">

</style>